<?php

class Cms_NewsletterController extends My_Controller_Action {

    public function indexAction() {
        // action body
        die('newsletter home');
    }

    public function addAction(){
        $mNewsletter = $this->loadModel('cms','Newsletter');
		$email = $this->_request->getParam('email');
		$category_id = $this->_request->getParam('category_id');
        
		$row = $mNewsletter->fetchRow($mNewsletter->select()->where('email=?',$email)->where('category_id=?',$category_id));
		if(!$row)
        {
			$newrow = $mNewsletter->createrow();
			$newrow->email = $email;
			$newrow->category_id = $category_id;
			$newrow->save();
			$this->_redirect('cms/newsletter/success');
		}
		else
		{
			$this->_redirect('cms/newsletter/unsuccess');
		}
		exit;
    }
    
    public function successAction(){
    
    }
    
    public function unsuccessAction(){
    }
}

